import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class HttpSessionServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取ip
        String ip = request.getRemoteAddr();
        // 获取会话状态
        HttpSession session = request.getSession();
        // 不同的用户访问会有不同的Session
        // 如果用户不变, 连续访问, Session也不变
        System.out.println(ip + "的Session为" + session);
    }
}
